import MyHeader from "../components/detail/MyHeader";
import Swiper from "../components/detail/Swiper";
import Operate from "../components/detail/Operate";
import { good_goodinfo } from "../utils/api";
import { Toast } from "antd-mobile";
import React, { Component } from 'react';

class Detail extends Component {
    state={
        goodinfo:{}
    }
    componentDidMount(){
        good_goodinfo({goodid:this.props.location.state.id}).then((res)=>{
            if(res.data.code==200){
                this.setState({
                    goodinfo:res.data.goodinfo
                })
            }else if(res.data.code==400){
                Toast.show({
                    icon: 'fail',
                    content: res.data.msg,
                })
                this.props.history.goBack()
            }
        })

    }
    render() {
        return (
            <div className="detail">
                <MyHeader></MyHeader>
                <Swiper pics={this.state.goodinfo.pics}></Swiper>
                <Operate goodinfo={this.state.goodinfo}></Operate>
            </div>
        );
    }
}

export default Detail;